package com.flowable.service;

import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.task.api.Task;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 长沙先飞信息科技有限公司<br>
 * Created with IntelliJ IDEA.<br>
 * Date:2024/6/19<br>
 * Time:15:01<br>
 * 功能描述：<br>
 *
 * @author huang hou chun
 * @since JDK 1.8 <br>
 * Copyright (c) 2023 www.csxfrj.com System Incorporated All Rights Reserved.
 */
@Service
public class MyService {

    @Resource
    private RuntimeService runtimeService;
    @Resource
    private TaskService taskService;

    @Transactional(rollbackFor = Exception.class)
    public void startProcess() {
        runtimeService.startProcessInstanceByKey("one-task-process");
    }

    @Transactional(rollbackFor = Exception.class)
    public List<Task> getTasks(String assignee) {
        return taskService.createTaskQuery()
                .taskAssignee(assignee)
                .list();
    }
}
